<?

if ($DATA['component']['id']) {
	
	$_record = array('id_data' => D_MB_SETTINGS, 'id_parent' => $DATA['component']['id'], 'assoc' => '');

	$_lang_indep = array(
		'path' => 'gallery', 
		'w' => 800, 'h' => 600, 
		'tnw' => 128, 'tnh' => 96, 'imode' => MI_FIT, 'tnmode' => MI_FIT,
		'gw' => 128, 'gh' => 96, 
		'gtpb' => 0,
		'param' => 'id', 
		'show_tn' => 1, 'nav' => 0, 'navigator' => 1, 'circular' => 0, 'autoscroll' => 0, 'fancybox' => 0);

	$_lang_dep	= array('caption');	// which fields are stored in language variations

	switch (action(array('editor_save'))) {
	
		case 'editor_save':

			$temp = array();
			
			foreach($_lang_indep as $k => $v)
				$temp[] = array_merge($_record, array('name' => $k, 'value' => trim(postdata($k))));

			foreach($DATA['langs'] as $lang)
				foreach($_lang_dep as $k)
					if (isset($_POST[$k][$lang['text']]) && (($t = trim($_POST[$k][$lang['text']])) !== ''))
						$temp[] = array_merge($_record, array('name' => $k, 'value' => $t, 'assoc' => $lang['text']));	// language dependent data

			dataset('db_delete', tb('data'), "(id_data=".D_MB_SETTINGS.") AND (id_parent={$DATA[component][id]})");
			dataset('db_insert', tb('data'), $temp);
			
			return true;	// end of component edition
	}
	

	$DATA['settings'] = array_merge( $_lang_indep, datafetch_array('meta', D_MB_SETTINGS, $DATA['component']['id']));
	
	foreach($DATA['langs'] as $lang)
		$DATA['settings']['data'][$lang['text']] = datafetch_array('meta', D_MB_SETTINGS, $DATA['component']['id'], $lang['text']);
		
	return false;

} else exit;
